<template>
  <a-card :bordered="false">
    <a-card title="用户详情" size="small" style="margin-bottom:15px;line-height:40px;">
      <a-row :gutter="24" style="border-bottom:solid 1px #dddddd;text-align:center;">
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          昵称/手机号
        </a-col>
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          当前等级
        </a-col>
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          待结算佣金
        </a-col>

        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          已结算佣金
        </a-col>
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          佣金总计
        </a-col>
        <!-- <a-col :xl="3" :lg="3" :md="3" :sm="24">
          已提现金额
        </a-col>
        <a-col :xl="3" :lg="3" :md="3" :sm="24">
          已使用金额
        </a-col> -->
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          身份渠道
        </a-col>
      </a-row>
      <a-row :gutter="24" style="text-align:center;">
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          {{memberinfoParams.nickname}}/{{memberinfoParams.phone}}
        </a-col>
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          {{memberinfoParams.levelName}}
        </a-col>
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          {{memberinfoParams.unSum}}
        </a-col>
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          {{memberinfoParams.sumed}}
        </a-col>
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          {{memberinfoParams.sum}}
        </a-col>
        <!-- <a-col :xl="3" :lg="3" :md="3" :sm="24">
          {{memberinfoParams.cashSum}}
        </a-col>
        <a-col :xl="3" :lg="3" :md="3" :sm="24">
          {{memberinfoParams.paySum}}
        </a-col> -->
        <a-col :xl="4" :lg="4" :md="4" :sm="24">
          {{memberinfoParams.channel == 1 ? '线上买礼包' : memberinfoParams.channel == 3 ? '后台变更身份' : '任务升级'}}
        </a-col>
      </a-row>
    </a-card>
    <a-card title="佣金明细列表" size="small" style="margin-bottom:15px;">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="时间">
                <a-range-picker format="YYYY-MM-DD" :placeholder="['开始时间', '结束时间']" @change="onDateChange" />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="订单状态">
                <a-select :default-value="null" v-model="queryParam.orderStatus" @change="searchQuery">
                  <a-select-option :value="null">
                    全部
                  </a-select-option>
                  <a-select-option :value="1">
                    待付款
                  </a-select-option>
                  <a-select-option :value="2">
                    走款中
                  </a-select-option>
                  <a-select-option :value="3">
                    待发货
                  </a-select-option>
                  <a-select-option :value="4">
                    已发货
                  </a-select-option>
                  <a-select-option :value="5">
                    待评价
                  </a-select-option>
                  <!-- <a-select-option :value="6">
                  交易取消
                </a-select-option> -->
                  <a-select-option :value="7">
                    交易完成
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="结算状态">
                <a-select :default-value="null" v-model="queryParam.isSettled" @change="searchQuery">
                  <a-select-option :value="null">
                    全部
                  </a-select-option>
                  <a-select-option :value="0">
                    未结算
                  </a-select-option>
                  <a-select-option :value="1">
                    已结算
                  </a-select-option>
                  <a-select-option :value="2">
                    退款中
                  </a-select-option>
                  <a-select-option :value="3">
                    已退款
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>

            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <!-- <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button> -->
                <a-button type="primary" icon="download" @click="handleExportXls('佣金明细')" style="margin-left: 8px">导出</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- 查询区域-END -->

      <!-- table区域-begin -->
      <div>
        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>

        <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
          :pagination="ipagination" :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          class="j-table-force-nowrap" @change="handleTableChange">

          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="settlementStatus" slot-scope="text,record">
            <span v-if="record.refundNo">{{record.refundStatus==2?'退款成功':'退款中'}}</span>
            <span v-else>{{text==1?'已结算':'未结算'}}</span>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
            <img v-else :src="getImgView(text)" height="55px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;" />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
              下载
            </a-button>
          </template>

        </a-table>
      </div>
    </a-card>

  </a-card>
</template>

<script>
import { putAction, getAction, postAction } from '@/api/manage'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/MyJeecgListMixin'
import JDate from '@/components/jeecg/JDate.vue'

export default {
  name: 'UmsBalanceLogList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    JDate
  },
  data () {
    return {
      description: '佣金明细管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '昵称',
          align: "center",
          dataIndex: 'nickname'
        },
        {
          title: '手机号',
          align: "center",
          dataIndex: 'phone'
        },
        {
          title: '所属订单号',
          align: "center",
          dataIndex: 'orderNo'
        },
        {
          title: '所属订单状态',
          align: "center",
          dataIndex: 'orderStatus_dictText'
        },
        {
          title: '订单实付金额',
          align: "right",
          dataIndex: 'payAmount'
        },
        {
          title: '佣金金额',
          align: "right",
          dataIndex: 'amount'
        },
        {
          title: '佣金名称',
          align: "right",
          dataIndex: 'title'
        },
        {
          title: '结算状态',
          align: "center",
          dataIndex: 'isSettled',
          scopedSlots: { customRender: 'settlementStatus' }
        }
      ],
      url: {
        list: "/member/umsBalanceLog/customList",
        exportXlsUrl: "/member/umsBalanceLog/exportXls"

      },
      dictOptions: {},
      memberinfoParams: {}
    }
  },
  created () {
    if (this.$route.query.id) {
      this.queryParam.uid = this.$route.query.id
    }
    this.loadData()
    this.getInfo()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    getInfo () {
      getAction("/tipMember/queryById", { id: this.queryParam.uid }).then((res) => {
        if (res.success) {
          this.memberinfoParams = res.result
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },
    initDictConfig () {
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
